< previous page page_836 next page >

Page 836
Listing 21.38. continued
    ' open existing file
    Open strFileName For Append As intFileHandle
    '
End Sub

Private Sub WriteHeader()
    '
    ' send out standard header
    '
    Print #intFileHandle, String(60, "*")
    Print #intFileHandle, strHeader
    Print #intFileHandle, "Created: " & Format(Now(), "general date")
    Print #intFileHandle, String(60, "*")
    Print #intFileHandle, ""
    '
End Sub
Notice that the OpenLogFile method first checks to see whether the file exists. If it does not, a new one is created and a log header is written to the new file.
Now add the final routine, ClearLog. This one allows you to clear an existing log file and start out fresh. Add the code from Listing 21.39 to your class module.
Type.gifListing 21.39. Coding the ClearLog method.
Public Sub ClearLog()
    '
    ' clear all records from the log
    '
    On Error GoTo LocalErr
    '
    Dim intFile As Integer
    '
    intFile = FreeFile
    '
    Open strFileName For Output As intFile
    WriteHeader
    Close #intFile
    '
    Exit Sub
    '
LocalErr:
    Err.Raise Err.Number, App.EXEName & ".logObject", Err.Description
    '
End Sub
Now save the DLL project again. You have created all the routines you need in order to add detailed audit trails to any Visual Basic project. This is the last of the modifications to the prjUsrObject DLL library. But before going on to the next section, let's make a final modification to the test project to verify that the audit routines are working.

 
< previous page page_836 next page >

If you like this book, buy it!